package com.ny.demo529;

import java.util.*;

public class TestMap {
    public void addEmp(Map<String, Emp> map, Emp emp) {
        map.put(emp.getNumber(), emp);
    }

    public void findAllEmp(Map<String, Emp> map) {
        for (Emp emp : map.values()) {
            System.out.println(emp);
        }
    }

    public void findEmpName(Map<String, Emp> map, String name) {
        for (Emp emp : map.values()) {
            if (name.equals(emp.getName())) {
                System.out.println(emp);
            }
        }
    }

    public void deleteEmpNumber(Map<String, Emp> map, String number) {
        map.remove(number);
        System.out.println(map.values());
    }

    public void findNumber(Map<String, Emp> map, String number) {
        Emp emp = map.get(number);
        if (emp != null) {
            System.out.println(emp);
        }
    }

    public Emp findEmpNumber(Map<String, Emp> map, String number) {
        return map.get(number);
    }

    public void updateEmpAge(Map<String, Emp> map, Emp emp) {
        if (map.containsKey(emp.getNumber())) {
            map.put(emp.getNumber(), emp);
        }
    }
}